package com.yanqu.road.server.cmd.musicroom;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.MusicRoomProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.musicroom.MusicRoomModule;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_MUSIC_ROOM_BUILDING_FURNITURE_UP, desc = "妙音坊 家具升级")
public class MusicRoomFurnitureLvUpCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        MusicRoomProto.MusicRoomFurnitureUpgradeReqMsg reqMsg = MusicRoomProto.MusicRoomFurnitureUpgradeReqMsg.parseFrom(packet.getBytes());
        ret = player.getModule(MusicRoomModule.class).furnitureUpgrade(reqMsg.getBuildId(), reqMsg.getFurnitureId(), reqMsg.getLvUpNum());
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret > 0) {
            player.sendPacket(ClientProtocol.U_MUSIC_ROOM_BUILDING_FURNITURE_UP, MusicRoomProto.MusicRoomFurnitureUpgradeRespMsg.newBuilder().setRet(ret));
        }
    }
}
